package com.itheima.service.impl;

import com.itheima.dao.UserDao;
import com.itheima.dao.impl.UserDaoImpl;
import com.itheima.domain.User;
import com.itheima.service.UserService;

import java.sql.SQLException;

public class UserServiceImpl implements UserService {
    UserDao userDao = new UserDaoImpl();

    @Override
    public boolean isRegiser(User u) {
        try {
            int i = userDao.addUser(u);
            if (i > 0) {
                return true;
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return false;
    }

    @Override
    public boolean isLogin(User u) {
        User user = null;
        try {
            user = userDao.query(u);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return user != null;
    }

}
